/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap')

window.Vue = require('vue')

Vue.prototype.authorize = function(hander) {
  // if Admin,just return true
  let user = window.App.user

  return user ? hander(user) : false
}

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

window.events = new Vue()

window.flash = function(message) {
  window.events.$emit('flash', message)
}
window.log = console.log.bind(console)

Vue.component('Flash', require('./components/Flash.vue'))
Vue.component('ThreadView', require('./pages/Thread'))

const app = new Vue({
  el: '#app',
})
